# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Gmail.V1.Model.Message do
  @moduledoc """
  An email message.

  ## Attributes

  *   `historyId` (*type:* `String.t`, *default:* `nil`) - The ID of the last history record that modified this message.
  *   `id` (*type:* `String.t`, *default:* `nil`) - The immutable ID of the message.
  *   `internalDate` (*type:* `String.t`, *default:* `nil`) - The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
  *   `labelIds` (*type:* `list(String.t)`, *default:* `nil`) - List of IDs of labels applied to this message.
  *   `payload` (*type:* `GoogleApi.Gmail.V1.Model.MessagePart.t`, *default:* `nil`) - The parsed email structure in the message parts.
  *   `raw` (*type:* `String.t`, *default:* `nil`) - The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied.
  *   `sizeEstimate` (*type:* `integer()`, *default:* `nil`) - Estimated size in bytes of the message.
  *   `snippet` (*type:* `String.t`, *default:* `nil`) - A short part of the message text.
  *   `threadId` (*type:* `String.t`, *default:* `nil`) - The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match. 
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :historyId => String.t() | nil,
          :id => String.t() | nil,
          :internalDate => String.t() | nil,
          :labelIds => list(String.t()) | nil,
          :payload => GoogleApi.Gmail.V1.Model.MessagePart.t() | nil,
          :raw => String.t() | nil,
          :sizeEstimate => integer() | nil,
          :snippet => String.t() | nil,
          :threadId => String.t() | nil
        }

  field(:historyId)
  field(:id)
  field(:internalDate)
  field(:labelIds, type: :list)
  field(:payload, as: GoogleApi.Gmail.V1.Model.MessagePart)
  field(:raw)
  field(:sizeEstimate)
  field(:snippet)
  field(:threadId)
end

defimpl Poison.Decoder, for: GoogleApi.Gmail.V1.Model.Message do
  def decode(value, options) do
    GoogleApi.Gmail.V1.Model.Message.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Gmail.V1.Model.Message do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
